<template>
  <div>
    <div id="main"></div>
  </div>
</template>

<script>
import * as echarts from "echarts";
export default {
  name: "Test",
  mounted() {
    var myChart = echarts.init(document.getElementById("main"));
    myChart.setOption({
      titile: {
        Text: "柱状图",
        x: "center",
        background: "red",
      },
      tooltip: {
        trigger: "axis",
        axisPointer: {
          type: "shadow",
        },
      },
      legend: {
        show: true,
        left: "10%",
        icon: "circle",
      },

      xAxis: {
        data: ["苹果", "香蕉", "橘子", "火龙果", "芒果", "葡萄"],
      },
      yAxis: {},
      series: [
        {
          name: "销量",
          type: "bar",
          data: [333, 133, 299, 133, 222, 222],
          itemStyle: {
            color: function (params) {
              let mycolor = ["red", "yellow", "blue", "black", "pink", "green"];
              return mycolor[params.dataIndex];
            },
          },
          markPoint: {
            data: [
              {
                type: "max",
                value: "最大值",
              },
              {
                type: "min",
                value: "最小值",
              },
            ],
          },
        },
      ],
    });
  },
  methods: {},
};
</script>

<style scoped>
#main {
  height: 600px;
  width: 500px;
}
</style>
